package com.bdtop.dbl.ui.adapters;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.bdtop.dbl.R;
import com.bdtop.dbl.model.Log;

import java.util.ArrayList;

public class LogListAdapter extends ArrayListAdapter<Log>{
    
   // public Map<String, String> logMap;

    public LogListAdapter(Activity context) {
        super(context);
        
        mList = new ArrayList<Log>();
        //logMap=new HashMap<String, String>();
        //logMap.put("LOGIN", context.getResources().getString(R.string.log_login));
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View row = convertView;
        ViewHolder holder;

        if (null == row) {
            row = LayoutInflater.from(mContext).inflate(R.layout.listitem_log, null);

            holder = new ViewHolder();
            holder.tvType = (TextView) row.findViewById(R.id.log_type);
            holder.tvDate = (TextView) row.findViewById(R.id.log_date);

            row.setTag(holder);
        }
        else {
            holder = (ViewHolder) row.getTag();
        }

        Log log = mList.get(position);
        holder.tvType.setText(log.getActdesc());
        holder.tvDate.setText(log.getTime());

        return row;
    }

    class ViewHolder{
        TextView tvType;
        TextView tvDate;
    }

}
